package org.wuzhou.lvyou.activity;

import org.wuzhou.lvyou.R;
import org.wuzhou.lvyou.base.BaseActivity;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;

public class HelperActivity extends BaseActivity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.helper);
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if(keyCode==KeyEvent.KEYCODE_BACK){//返回键用户确认是否返回主界面
			_backToMain();
		}
		return false;
	}

	private void _backToMain(){//返回主界面 函数
		Dialog dialog=new AlertDialog.Builder(HelperActivity.this)
		.setTitle("返回主界面？")
		.setMessage("您确定要返回主界面吗？")
		.setPositiveButton("确定", new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				HelperActivity.this.gotoActivity(HelperActivity.this, MainActivity.class);
			}
		}).setNegativeButton("取消",new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				
			}
		}).create();//创建一个对话框
		dialog.show();//显示对话框
	}
}
